import Router from 'koa-router';
const router = new Router();
import proxyService from '../../common/proxyService';
import {
  getAgentList,
  updateAgent,
  deleteAgent,
  getAgentInfo,
  getAgentAccountView,
  getAgentAccountConsume,
  getAgentAccountReVenue,
  agentLastschrift,
  agentRecharge,
  agentDeduction,
  saveAgent,
  uploadCloudToken,
  getValueByKey,
} from '../../api/agent';
// 获取
router.get('/getAgentList', async ctx => {
  const response = await proxyService.postProxy(ctx, getAgentList);
  return (ctx.body = response);
});

// 获取
router.post('/updateAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, updateAgent);
  return (ctx.body = response);
});

router.post('/deleteAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, deleteAgent);
  return (ctx.body = response);
});

// 获取
router.get('/getAgentInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, getAgentInfo);
  return (ctx.body = response);
});

// 获取
router.get('/getAgentAccountView', async ctx => {
  const response = await proxyService.postProxy(ctx, getAgentAccountView);
  return (ctx.body = response);
});

// 获取
router.get('/getAgentAccountConsume', async ctx => {
  const response = await proxyService.postProxy(ctx, getAgentAccountConsume);
  return (ctx.body = response);
});

// 获取
router.get('/getAgentAccountReVenue', async ctx => {
  const response = await proxyService.postProxy(ctx, getAgentAccountReVenue);
  return (ctx.body = response);
});

router.post('/agentLastschrift', async ctx => {
  const response = await proxyService.postProxy(ctx, agentLastschrift);
  return (ctx.body = response);
});

// 获取
router.post('/agentRecharge', async ctx => {
  const response = await proxyService.postProxy(ctx, agentRecharge);
  return (ctx.body = response);
});

router.post('/agentDeduction', async ctx => {
  const response = await proxyService.postProxy(ctx, agentDeduction);
  return (ctx.body = response);
});

// 获取
router.post('/saveAgent', async ctx => {
  const response = await proxyService.postProxy(ctx, saveAgent);
  return (ctx.body = response);
});

router.get('/uploadCloudToken', async ctx => {
  const response = await proxyService.postProxy(ctx, uploadCloudToken);
  return (ctx.body = response);
});

router.get('/getValueByKey', async ctx => {
  const response = await proxyService.postProxy(ctx, getValueByKey);
  return (ctx.body = response);
});

module.exports = router;
